package com.bbcare.followup.plat.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bbcare.comm.AppException;
import com.bbcare.comm.Constants;
import com.bbcare.comm.ErrorCode;
import com.bbcare.comm.ResultModel;
import com.bbcare.plat.consumer.service.impl.ConsumerListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;


@Controller
@RequestMapping("/webapi/mqSwitch")
public class MqSwitchController {
    private final Log logger = LogFactory.getLog(AppEvaluationController.class);

    @Autowired
    private ConsumerListener consumerListener;
    public ResultModel<Object> getMonthlyPostion(@RequestBody String arg,
                                                 HttpServletRequest request) throws Exception {
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
        if(null == requestParam){
            throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
        }
        consumerListener.doCosumer(requestParam.toString());

        return new ResultModel<Object>("ok");
    }
}
